<template>
	<view class="bgc content">
		<video :src="vedios[0].image" objectFit="cover" controls></video>
		<image lazy-load :src="item.image" :key="index" mode="widthFix" v-for='(item,index) in imgDetails'></image>
		<footer-index></footer-index>
		<button @click="goto" class="btn-primary btn-foot">去预约</button>
	</view>
</template>

<script>
	import footerIndex from '@/components/footer/footer.vue'
	import { getDataForIndex } from '@/service/index';
	export default {
		name: "Index",
		components: {
			footerIndex
		},
		data() {
			return {
				imgDetails: [],
				vedios: []
			}
		},
		onLoad() {
			if (uni.getStorageSync('indexDataInfo')) { // 有缓存时获取缓存数据
				this.setData(uni.getStorageSync('indexDataInfo'))
				uni.removeStorageSync('indexDataInfo')
			} else { // 没有数据时获取数据
				this.getData()
			}
		},
		methods: {
			getData() {
				getDataForIndex(0, 999).then(res => {
					this.setData(res.data)
				}).catch(err => {
					console.log(err)
				})
			},
			setData(res) {
				this.imgDetails = res.images
				this.vedios = res.vedios
			},
			goto() {
				uni.navigateTo({url: '/pages/select/choose'})
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}
	video{
		width:100vw;
		height:300rpx
	}
	image {
		width: 710rpx;
		margin: 0 20rpx;
	}
</style>
